<?php
	$url = "#allDeals/";
	if(isset($filter)) {
		$url .= "filter/".$filter."/";
	}
	if(isset($sortby)) {
		$url .= "sortby/$sortby/";	
	}
	$url.="page/"
?>
						
						<ul class="breadcrumb well">
						    <li><a href="#">Финансы</a> <span class="divider">/</span></li>
						    <li class="active">Все отчеты</li>
					    </ul>

						<div class="content well content-wide">
					    	    <table class="table table-bordered table-hover">
					    	    	<thead>
										<tr>
											<td>ID</td>
											<td>Название предложения</td>
											<td>Тип</td>
											<td>Город</td>
											<td>Дата добавления</td>
											<td>Партнер</td>
											<td>Менеджер</td>
											<td>Статус</td>
											<td>Документы</td>
											<td>Акции</td>
											<td class="muted">Операции</td>
										</tr>
									</thead>

									<tbody>

					    	    		<?php foreach($deals as $deal){ 
					    	    			if(isset($filter)){
						    	    			if($filter == "me"){
						    	    				if($deal->manager != $session_name){
						    	    					continue;
						    	    				}
						    	    			}
						    	    		}
					    	    		?>
										<tr class="text-normal">
											<td><?php echo $deal->id; ?></td>
											<td><?php echo $deal->dealname; ?></td>
											<td><?php echo idToCouponType($deal->coupontype); ?></td>
											<td><?php echo $deal->city; ?></td>
											<td><?php echo $deal->dealstartdate; ?></td>
											<td><?php echo $deal->partner; ?></td>
											<td><?php echo $deal->manager; ?></td>
											<td><?php echo idToStatus($deal->status); ?></td>
											<td><a href="#viewDocuments/did/<?php echo $deal->id;?>">Прикрепленные документы</a></td>
											<td><a href="#products/id/<?php echo $deal->id;?>">Акции</a></td>
											
											<td class="muted">
												<div class="dropdown">
								    				<a class="dropdown-toggle btn" data-toggle="dropdown">Операции <b class="caret"></b> </a>
								    					<ul class="dropdown-menu">
								    						<?php if(($deal->manager == $session_name || $session_position == 0) && $deal->status != 3){?>
								    						<li><a href="#acceptDeal/id/<?php echo $deal->id; ?>"><i class="icon-ok"></i> Подтвердить</a> </li>
								    						<?php }?>
								    						<li><a href="#viewDeal/id/<?php echo $deal->id;?>"><i class="icon-eye-open"></i> Просмотреть</a></li>
								    						<?php if($deal->manager == $session_name || $session_position == 0){?>
								    						<li><a href="#deleteDeal/id/<?php echo $deal->id;?>"><i class="icon-trash"></i> Удалить</a></li>
								    						<li><a href="#blockDeal/id/<?php echo $deal->id;?>"><i class="icon-remove"></i> Отвергнуть </a> </li>
								    						<li><a href="#sendToCorrectionDeal/id/<?php echo $deal->id;?>"><i class="icon-share-alt"></i> На исправление </a> </li>		
								    						<li><a href="#editDeal/id/<?php echo $deal->id; ?>"><i class="icon-edit"></i> Изменить</a> </li>
								    						<?php }?>
								    					</ul>
							    				</div>
											</td>
										</tr>
										<?php }?>		
									</tbody>

    							</table>
					    </div> <!-- /content -->

					    
					    <!-- pagination -->
					    <?php include("pagination.php");?>